package com.javaAPI.demo12;

import java.util.Calendar;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {

        System.out.println("判断2月有多少天,请输入年份：");
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();

        Calendar instance = Calendar.getInstance();
        //设置时间3月1日
        instance.set(i, 2, 1);
        //修改日期，-1天
        instance.add(Calendar.DATE, -1);

        int date = instance.get(Calendar.DATE);
        System.out.println(i + "年2月共有" + date + "天");

        System.out.println(date == 29 ? "闰年" : "平年");

    }
}
